package com.hy.erp.inventory.service;

import java.util.List ;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

/*import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
import org.jboss.seam.async.Schedule ;
*/
import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.PositionDao;
import com.hy.erp.inventory.dao.StockTypeDao;
import com.hy.erp.inventory.dao.interfaces.IStockTypeDao;
import com.hy.erp.inventory.dao.interfaces.IUserDao;
import com.hy.erp.inventory.pojo.StockType;
import com.hy.erp.inventory.pojo.interfaces.IStockType;
import com.hy.erp.inventory.pojo.interfaces.IUser;
import com.hy.erp.inventory.service.interfaces.IStockTypeService;
/**
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-10-12；时间：下午02:35:10</li>
 * <li>字段类型：long；字段名称：serialVersionUID</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
/*@Name("stockTypeService")
@Scope(ScopeType.SESSION)
@Stateless*/
@Component("stockTypeService")
public class StockTypeService	extends	AbstractBusinessService < StockTypeDao >	implements	IStockTypeService
{

	
	private static final long	serialVersionUID	=
														1747301179217694148L ;
	
    private IStockTypeDao stockTypeDao=null;
	
	

	@Resource(name="stockTypeDao")
	public void setPositionTypeDao(IStockTypeDao stockTypeDao) {
		this.stockTypeDao = stockTypeDao;
	}
	private IStockTypeDao dao=stockTypeDao;
	/**
	 * 
	 * 构造函数
	 */
	public StockTypeService()
	{
		super ( );
	}
	
	@ Override
	public boolean addStockType (
									StockType stockType )
	{
		if(stockType==null)
		{
			return true;
		}
		else
		{
			//IStockTypeDao dao=( IStockTypeDao ) this.getDao ( IStockType.class );
			//IStockType iStockType= stockType;
			return stockTypeDao.persist ( stockType ) ;
		}
	}

	@ Override
	public Integer removeStockType (
										String [ ] typeIds )
	{
		if ( ( null == typeIds )
			     || ( typeIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{
			//	IStockTypeDao dao=( IStockTypeDao ) this.getDao ( IStockType.class );
				return stockTypeDao.remove ( typeIds );
			}
	}

	@ SuppressWarnings ( "unused" )
	@ Override
	public boolean modifyStockType (
										StockType stockType )
	{
		if ( ( null == stockType ) || ( null == stockType.getIdentifier ( ) ))
		{
			return true;
		}
		else
		{
		//	IStockTypeDao dao=( IStockTypeDao ) this.getDao ( IStockType.class );
			//IStockType iStockType= stockType;
			
			if ( null == stockType )
			{
				throw new ArchitectureFoundationException (
				                                            "修改用户实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
			}
			return (stockTypeDao.merge ( stockType )!=null) ;
		}
	}

	@ Override
	public String [ ] addStockType (
										Object [ ] objects )
	{
		//IStockTypeDao dao=( IStockTypeDao ) this.getDao ( IStockType.class );
		StockType[] types=new StockType[objects.length];
		for ( int i =
						0 ; i < objects.length ; i ++ )
		{
			StockType stockType=( StockType ) objects[i];
			types[i]=stockType;
		}
		return stockTypeDao.persist ( types ) ;
	}

	@ Override
	public List < StockType > getAllStockType ( )
	{
		//IStockTypeDao dao=( IStockTypeDao ) this.getDao ( IStockType.class );
		return stockTypeDao.find ( ) ;
	}

	@ Override
	public String [ ] modifyStockType (
										Object [ ] objects )
	{
		if (  null == objects ) 
		{
			return null;
		}
		else
		{
			//IStockTypeDao dao=( IStockTypeDao ) this.getDao ( IStockType.class );
			StockType[] types=new StockType[objects.length];
            for(int i=0;i<objects.length;i++)
            {
            	StockType type=( StockType ) objects[i];
            	types[i]=type;
            }
			
			return dao.merge ( types );
		}
	}

}
